package com.sleepingcat.flutter_boost_android.activity

import android.os.Bundle
import android.os.Handler
import android.os.Looper
import androidx.navigation.NavController
import com.cat.android.lib_base.base.RouterActivity
import com.cat.android.lib_base.utils.NavGraphBuilder
import com.cat.android.plugin_navigation_runtime.NavData
import com.cat.android.plugin_navigation_runtime.NavDestination
import com.sleepingcat.flutter_boost_android.NavRegistry
import com.sleepingcat.flutter_boost_android.R
import com.sleepingcat.flutter_boost_android.databinding.ActivityMainBinding
import com.sleepingcat.ft_flutter.fragment.MyFlutterFragment
import com.sleepingcat.lib_common.const.Routes
//import com.tencent.bugly.crashreport.CrashReport

class MainActivity : RouterActivity<ActivityMainBinding>() {

    private val handle = Handler(Looper.getMainLooper())

    override fun controllerId(): Int {
        return R.id.navHost
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        /*CrashReport.initCrashReport(applicationContext, "ce7416bd43", true)

        handle.postDelayed(object : Runnable {
            override fun run() {
                CrashReport.postCatchedException(Exception("哈拉哈啊哈"))
            }
        }, 3000)*/
    }

    override fun setGraph(navController: NavController) {
        val list = NavRegistry.getList() as ArrayList<NavData>
        list.add(NavData(type = NavDestination.NavType.Fragment, route = Routes.SingleFlutterFragment.SINGLE_FLUTTER_FRAGMENT, className = MyFlutterFragment::class.java.canonicalName!!))
        val graph = NavGraphBuilder.build(list, navController, this)
        navController.setGraph(graph, null)
    }

}
